package com.example.admin.service.impl;

import com.example.dao.domain.dto.LoginDto;
import com.example.dao.domain.entity.UserEntity;
import com.example.dao.mapper.UserMapper;
import com.example.admin.service.UserService;
import com.example.util.result.RestResult;
import com.example.util.result.RestResultBuilder;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

@Service
public class UserServiceImpl implements UserService {
    @Resource
    private UserMapper userMapper;

    @Override
    public RestResult queryUserByNameAndPwd(LoginDto loginDto) throws Exception {
        UserEntity user = userMapper.queryUserByNameAndPwd(loginDto.getAccount(), loginDto.getPassword());

        if (user == null) {
            throw new Exception("查无此人");
        }

        return new RestResultBuilder().success(user);
    }
}
